#include "fileparserfactory.h"

#include <QMessageBox>

BaseFileParser *FileParserFactory::createFileParser(const std::string &fileName)
{
    int idx = static_cast<int>(fileName.find_last_of('.'));
    std::string suffix = std::string(std::begin(fileName)+idx+1,std::end(fileName));
    // if-else代替
    if(suffix == "json"){
       return new JsonFileParser;
    }else{
        QMessageBox::information(nullptr,"结束","结束");
        exit(-1);
    }
}

FileParserFactory &FileParserFactory::instance()
{
    static FileParserFactory fpf;
    return fpf;
}
